import http from '@/utils/request'
import { toLower } from 'lodash'

export const fetchIntegration = params =>
  http.get(`/web/task-management/sys/tenant/connector/showIntegrations`, {
    params
  })

export const fetchDropIntegration = params =>
  http.post(`/web/reports/sys/widget-list/integration-list`, params)

export const syncCustomize = ({
  tenantCode,
  method,
  client,
  path,
  ...params
}) =>
  http[toLower(method)](
    `/web/dm/sync/customize/${tenantCode}/${toLower(method)}`,
    method === 'POST'
      ? {
          client,
          path,
          params
        }
      : {
          params: {
            client,
            path,
            ...params
          }
        }
  )
